import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['font.family'] = 'SimHei'
plt.rcParams['font.size'] = 12

bar_width = 0.15

date = np.array(['第1天', '第2天', '第3天'])
movie = np.array(['猩球崛起3', '敦刻尔克', '蜘蛛侠', '战狼2'])
data = np.array([
    [2358, 399, 2358, 362],
    [12357, 156, 2045, 168],
    [15746, 312, 4497, 319]
])
data = data.transpose()

fig = plt.figure('Bar Chart', figsize=(16, 8))

plt.title('电影票房条形图', size=24)
plt.xlabel('电影名')
plt.ylabel('票房（亿）')
plt.xticks(np.arange(len(data[0])), date, rotation=45)

plt.bar(np.arange(len(data[0])), data[0], width=bar_width, label=movie[0], zorder=100)
plt.bar(np.arange(len(data[1])) + bar_width, data[1], width=bar_width, label=movie[1], zorder=100)
plt.bar(np.arange(len(data[2])) + 2 * bar_width, data[2], width=bar_width, label=movie[2], zorder=100)
plt.bar(np.arange(len(data[3])) + 3 * bar_width, data[3], width=bar_width, label=movie[3], zorder=100)

plt.legend(loc='best')
plt.grid(alpha=0.4, zorder=0)
plt.show()
